package com.org.javabody.breakapi;

/**
 * 证明break能否跳出双循环
 * Created by Administrator on 2017-01-17.
 */
public class BreakBoth {

    public static String getInteger() {
        int x = 0;
        int y = 0;
        for(int i=0; i < 3; i++) {
            for (int j=0; j < 4; j++) {
                if(j==2) {
                    x += j;
                    break;
                }
            }
            y += i;
        }
        // x = 0+1+2+3;
        // y = 0+1+2;
        return "x="+x+";y="+y;
    }

    public static void main(String[] args) {
        String str = BreakBoth.getInteger();
        System.out.println(str); //break无法跳出双循环，只能跳出当前所在的那层循环
    }
}
